home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 22
/
Cream of the Crop 22.iso
/
program
/
jdp1_4.zip
/
JDP1_4.EXE
/
data.1
/
JDPLayout5.java
< prev
next >
Wrap
Text File
|
1996-11-07
|
15KB
|
512 lines
>XXX0500 Total lines for the build status message calculation
//--------------------------------------------------------------------
//
>001// Module: <JDPModule>
>002// Description: <Class Description>
//
//--------------------------------------------------------------------
import java.awt.*;
import java.applet.*;
import java.util.StringTokenizer;
import java.util.Vector;
>003public class <JDPUserBill> extends JDPClassLayout {
JDPUser user;
JDPJagg jaggSQL;
JDPWhereClause jdpWhereClause;
JDPSearchResults searchResults;
JDPChart chartPanel;
JDPChartParms p;
Choice thisChartType;
Choice thisAutoScale;
Choice thisAutoZoom;
String[] psortChoice;
String[] pdisplayChoice;
int itemIndex;
boolean insertRequested = false;
boolean deleteRequested = false;
String pfromWhereClause;
String prevSQL = "";
Color[] colorList = {Color.blue,Color.cyan,Color.green,Color.magenta,Color.orange,
Color.red,Color.white,Color.yellow,Color.pink,Color.black,
Color.darkGray,Color.gray};
Vector pmatchUsing;
Vector pactualmatchUsing;
public void InitClass(JDPUser user, Panel targetPanel, String moduleParameter) {
this.user = user;
//
// Set JAGG settings for this class
//
jaggSQL = new JDPJagg(user.jaggPath);
jaggSQL.setNULL("space");
>994 jaggSQL.setMRW("<maxRows>");
>998 jaggSQL.setDSN("<datasource>");
>999 jaggSQL.setCSTR("<connectstr>");
setLayout(new BorderLayout());
setFont(user.plainFont);
Panel mainPanel = new Panel();
mainPanel.setLayout(new BorderLayout());
Panel chartMainPanel = new Panel();
chartMainPanel.setLayout(new BorderLayout());
Panel centerPanel = new Panel();
centerPanel.setLayout(new BorderLayout());
Panel centerMainPanel = new Panel();
centerMainPanel.setLayout(new BorderLayout());
Panel centerTopPanel = new JDPScrollPanel();
Panel leftPanel = new Panel();
leftPanel.setLayout(new BorderLayout());
p = new JDPChartParms();
>140 p.chartType = <>;
thisChartType = new Choice();
thisChartType.addItem("Column");
thisChartType.addItem("Bar");
thisChartType.addItem("Line");
thisChartType.addItem("Area");
thisChartType.addItem("Pie");
thisChartType.select(p.chartType-1);
>154 p.autoscale = <>;
thisAutoScale = new Choice();
thisAutoScale.addItem("Yes");
thisAutoScale.addItem("No");
if (!p.autoscale) thisAutoScale.select("No");
>155 p.autozoom = <>;
thisAutoZoom = new Choice();
thisAutoZoom.addItem("Yes");
thisAutoZoom.addItem("No");
if (!p.autozoom) thisAutoZoom.select("No");
chartPanel = new JDPChart(user,p);
chartMainPanel.add("Center",chartPanel);
mainPanel.add("Center",chartMainPanel);
Panel controlPanel = new Panel();
controlPanel.setLayout(new JDPLineLayout(3));
chartMainPanel.add("South",controlPanel);
controlPanel.add("Left",new JDPWrapLabel(user,"Type:"));
controlPanel.add("Left",thisChartType);
controlPanel.add("Left",new JDPWrapLabel(user,"Auto Scale:"));
controlPanel.add("Left",thisAutoScale);
controlPanel.add("Left",new JDPWrapLabel(user,"Auto Zoom:"));
controlPanel.add("Left",thisAutoZoom);
//
// Define parameters for JDPSearchResults
//
>005 String pselectFields = "<>"; String[] psdisplayFields = {<>};
>006 pfromWhereClause = "<FROM JDPUser WHERE >";
>007 psortChoice = new String[<5>];
>008 psortChoice[<0>] = "<username>";
>009 String[] psortChoiceText = {<"Sort by User Name","Sort by Card Number">};
pdisplayChoice = psortChoice;
>010 boolean pdisplayCount = <true>;
>011 String pcountText = "<Total Entries:>";
//
// Define parameters for JDPWhereClause
//
>016 String[] pchooseFrom = new String[<7>];
>017 pchooseFrom[<0>] = "<Account Name>";
>018 String[] pactualchooseFrom = new String[<7>];
>019 pactualchooseFrom[<0>] = "<username>";
loadMatchUsing();
>024 boolean[] constantIsString = new boolean[<7>];
>025 constantIsString[<0>] = <true>;
>026 int[] constantLength = new int[<7>];
>027 constantLength[<0>] = <20>;
//
// Add JDPWhereClause search panel
//
boolean verticalPos = false;
if (psortChoice.length > 0) {
verticalPos = true;
}
if (pchooseFrom.length > 0) {
>028 jdpWhereClause = new JDPWhereClause(user, targetPanel, "<UserBill>", verticalPos, "<pinitChoice>", pchooseFrom, pactualchooseFrom,
pmatchUsing, pactualmatchUsing, null, null,
constantLength, constantIsString);
if (psortChoice.length > 0) {
leftPanel.add("North",jdpWhereClause);
} else {
mainPanel.add("North",jdpWhereClause);
}
}
//
// Add JDPSearchResults result list
//
if (psortChoice.length > 0) {
>029 searchResults = new JDPSearchResults(user, targetPanel, <false>, jaggSQL, <false>, pselectFields, psdisplayFields, pfromWhereClause, psortChoiceText, psortChoice, pdisplayChoice, "<pinitChoice>", pdisplayCount, pcountText);
>055 int icons[] = {<>};
>056 searchResults.setMinWidth(<>);
searchResults.setIcons(icons);
leftPanel.add("Center",searchResults);
mainPanel.add("West",leftPanel);
}
>030 add("Center",new JDPChiselFramePanel(user,"<User Billing Details>",mainPanel,"North"));
//
// Add the handle to this panel to the global vector so other panels can
// access this one
//
user.gParm.addElement(this);
newSearch();
}
//
// Handle screen events
//
public boolean handleEvent(Event e) {
switch (e.id) {
case Event.ACTION_EVENT:
if (e.target instanceof List) {
if (e.target.equals(searchResults.resultList)) {
loadChart();
chartPanel.calculateScaling();
chartPanel.repaint();
return true;
}
}
if (e.target instanceof JDPTreePicker) {
if (e.target.equals(searchResults.tree)) {
loadChart();
chartPanel.calculateScaling();
chartPanel.repaint();
return true;
}
}
if (e.target instanceof Button) {
String choice = (String)e.arg;
if (choice.trim().compareTo("Search") == 0) {
insertRequested = false;
deleteRequested = false;
newSearch();
return true;
}
return true;
}
if (e.target instanceof Choice) {
if ((e.target.equals(thisChartType)) ||
(e.target.equals(thisAutoScale)) ||
(e.target.equals(thisAutoZoom))) {
loadChart();
chartPanel.calculateScaling();
chartPanel.repaint();
return true;
}
return true;
}
if (e.target instanceof TextField) {
if ((jdpWhereClause != null) && (e.target.equals(jdpWhereClause.matchConstant))) {
insertRequested = false;
deleteRequested = false;
newSearch();
return true;
}
checkFields();
return true;
}
return false;
case Event.KEY_PRESS:
if (e.key == '\t') {
// handle tabbing between components
if (e.modifiers != Event.SHIFT_MASK) {
} else {
}
return true;
}
return false;
case Event.WINDOW_EXPOSE:
if (e.target instanceof JDPTabSelectPanel) {
//
// This is where you place code to get executed when this panel is
// reactivated from the tab menu
//
return true;
}
return false;
default:
return false;
}
}
//
// Retrieve the handle to another panel so as to be able to interact with it
//
public void retrieveHandle() {
for (int ix=0; ix<user.gParm.size(); ix++) {
//
// Activate the next four lines of code to retrieve the handle to another
// Panel within your JDP system. Of course you should declare the variable
// at the top of this source instead of within this method so you can
// access it from all the methods within this class. You only need to
// substitute DemoClass with the name ouf your class. You should call this
// method from somewhere else in this class. To access a variable from
// your resulting class use:
// if (DemoClassHandle != null) mynewvar = demoClassHandle.variable;
//
// if (user.gParm.elementAt(ix) instanceof DemoClass19) {
// DemoClass19 DemoClassHandle = (DemoClass19)user.gParm.elementAt(ix);
// return;
// }
}
}
//
// The search button was pressed so rerun the query with the new search criteria
//
public void newSearch() {
if (psortChoice.length > 0) {
String whereClause;
whereClause = pfromWhereClause;
if (jdpWhereClause != null) {
whereClause = whereClause + " AND " + jdpWhereClause.whereClause;
}
searchResults.setFromWhereClause(whereClause);
>057 searchResults.clearList(<>);
searchResults.loadList();
} else {
loadChart();
chartPanel.calculateScaling();
chartPanel.repaint();
}
}
//
// Load the selected item
//
public void loadData() {
StringTokenizer stok;
int recCount = 0;
Vector results = new Vector();
String sep = user.jaggSQL.getSEP();
int actualRows = 0;
String row;
String whereClause = "(1=1)";
if (psortChoice.length > 0) {
if ((itemIndex = searchResults.getSelectedIndex()) < 0) {
clearFields();
return;
}
}
if (jdpWhereClause != null) whereClause = jdpWhereClause.whereClause;
>130 int groupCount = <>;
>131 int seriesCount = <>;
>132 String SQL = "<SELECT >";
prevSQL = SQL;
user.mainmsg.setStatusMsg("Accessing database...", 0);
recCount = jaggSQL.execSQL(SQL, results);
if(recCount == -1) {
user.u.setSqlMessage(jaggSQL,SQL);
return;
}
//
// Initialise result arrays
//
int columnCount = jaggSQL.getColumnCount();
actualRows = jaggSQL.getRowCount();
if (seriesCount <= 0) {
p.chartData = new float[columnCount-groupCount][actualRows];
p.xaxisLabel = new String[actualRows];
p.piechartData = new float[actualRows];
p.pieSplitSegment = new boolean[actualRows];
p.pieLabel = new String[actualRows];
if (p.chartType == JDPChart.PIE) {
p.elementColor = new Color[actualRows];
p.elementBorderColor = new Color[actualRows];
p.elementLegend = new String[actualRows];
}
for (int ix=0; ix<actualRows; ix++) {
row = (String)results.elementAt(ix);
stok = new StringTokenizer(row);
p.xaxisLabel[ix] = "";
if (groupCount > 0) p.xaxisLabel[ix] = stok.nextToken(sep).trim();
for (int iz=0; iz<columnCount-groupCount; iz++) {
p.chartData[iz][ix] = Float.valueOf(stok.nextToken(sep).trim()).floatValue();
}
p.pieLabel[ix] = p.xaxisLabel[ix];
p.piechartData[ix] = p.chartData[0][ix];
if (p.chartType == JDPChart.PIE) {
p.elementColor[ix] = colorList[ix%12];
p.elementBorderColor[ix] = Color.black;
p.elementLegend[ix] = p.pieLabel[ix];
}
}
} else {
float[][] tempchartData = new float[1000][actualRows];
p.xaxisLabel = new String[actualRows];
Vector group = new Vector();
if (groupCount == 0) group.addElement("");
Vector series = new Vector();
for (int ix=0; ix<actualRows; ix++) {
row = (String)results.elementAt(ix);
stok = new StringTokenizer(row);
p.xaxisLabel[ix] = "";
int groupIndex = 0;
if (groupCount > 0) {
String groupValue = stok.nextToken(sep).trim();
groupIndex = group.indexOf(groupValue);
if (groupIndex < 0) {
group.addElement(groupValue);
groupIndex = group.indexOf(groupValue);
p.xaxisLabel[groupIndex] = groupValue;
}
}
String seriesValue = stok.nextToken(sep).trim();
int seriesIndex = series.indexOf(seriesValue);
if (seriesIndex < 0) {
series.addElement(seriesValue);
seriesIndex = series.indexOf(seriesValue);
}
tempchartData[seriesIndex][groupIndex] = Float.valueOf(stok.nextToken(sep).trim()).floatValue();
}
int numbars = series.size();
p.chartData = new float[numbars][group.size()];
for (int ix=0; ix<numbars; ix++) {
for (int iy=0; iy<group.size(); iy++) {
p.chartData[ix][iy] = tempchartData[ix][iy];
}
}
p.elementColor = new Color[numbars];
p.elementBorderColor = new Color[numbars];
p.elementLegend = new String[numbars];
for (int ix=0; ix<numbars; ix++) {
p.elementColor[ix] = colorList[ix%12];
p.elementBorderColor[ix] = Color.black;
p.elementLegend[ix] = (String)series.elementAt(ix);
}
}
user.mainmsg.clearStatusMsg();
}
//
// Clear the screen fields for a new option
//
public void clearFields() {
}
//
// Load all of the Screen Choices
//
public void loadChoices() {
}
//
// Perform component validations
//
public boolean checkFields() {
return true;
}
//
// Load the parameters for the selected chart
//
public void loadChart() {
p.chartType = thisChartType.getSelectedIndex()+1;
p.autoscale = thisAutoScale.getSelectedItem().equals("Yes");
p.autozoom = thisAutoZoom.getSelectedItem().equals("Yes");
>141 p.chartTitle = "<>";
p.chartTitleFont = user.boldFont.getName();
>142 p.chartTitleColor = user.u._cvtcolor("<>");
>143 p.xaxisTitle = "<>";
p.xaxisTitleFont = user.boldFont.getName();
>144 p.xaxisTitleColor = user.u._cvtcolor("<>");
p.yaxisLabel = new String[10];
p.elementLegendFont = user.boldFont.getName();
>145 p.xaxisLabelColor = user.u._cvtcolor("<>");
>146 p.yaxisLabelColor = user.u._cvtcolor("<>");
>147 p.chartFrameColor = user.u._cvtcolor("<>");
>148 p.elementLegend = new String[<>];
>148 p.elementColor = new Color[<>];
>148 p.elementBorderColor = new Color[<>];
>149 p.elementLegend[<iy>] = "<selectChartDef.elementLegend[ix]>";
>150 p.elementColor[<iy>] = user.u._cvtcolor("<>");
>151 p.elementBorderColor[<iy>] = user.u._cvtcolor("<selectChartDef.elementBorderColor[ix]>");
>152 p.gridLineSetting = <JDPChart.HORIZONTAL + JDPChart.VERTICAL + JDPChart.FOREGROUND + JDPChart.BACKGROUND>;
>153 p.gridColor = user.u._cvtcolor("<>");
>156 p.maxPlotValue = <>;
>157 p.minPlotValue = <>;
if ((p.chartType == JDPChart.COLUMN) || (p.chartType == JDPChart.BAR) ||
(p.chartType == JDPChart.AREA)) {
p.autozoom = false;
}
p.pieLabel = p.elementLegend;
p.pieLabelColor = p.xaxisTitleColor;
loadData();
}
//
// Load the Search Layout pulldown choices
//
public void loadMatchUsing() {
pmatchUsing = new Vector();
pactualmatchUsing = new Vector();
>020 pmatchUsing.addElement(new Vector());
>022 pactualmatchUsing.addElement(new Vector());
>021 ((Vector)pmatchUsing.elementAt(<0>)).addElement("<Begins with>");
>023 ((Vector)pactualmatchUsing.elementAt(<0>)).addElement("< like >");
}
}